/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upc.clase.demo.controller;

import edu.upc.clase.demo.entity.Credential;
import edu.upc.clase.demo.service.DistritoService;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author SP43791044
 */
@Controller("homeController")
public class HomeController {
    
    @Autowired
    ServletContext context;
    @Autowired
    DistritoService distritoService;
    
    
    @RequestMapping("/home/index")
    public ModelAndView index(HttpServletRequest request) {
        ModelAndView mav = new ModelAndView("home/index");
        Credential credential = new Credential();
        mav.getModelMap().put("credential", credential);
        
        request.getSession().setAttribute("contexto",context.getContextPath());
        request.getSession().setAttribute("distritoList",distritoService.buscarTodos());
        
        
        
        return mav;
    }
    
}
